﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HQWeb.SysManage.RoleManage
{
    public partial class RoleEdit : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            VerdictIsLogin();
            if (!IsPostBack)
            {
                string strType = Request["sigin"];
                if (strType.Equals("edit"))
                {
                    btnSend.CommandName = "edit";
                    string strID = Request["id"].Trim();
                    btnSend.CommandArgument = strID;
                    FillPage(strID);
                    labTitle.Text = "修改角色";
                }
            }
          
        }
        //页面填充
        private void FillPage(string strID)
        {
            BLL.SysManage.T_PUB_ROLE roleBll = new BLL.SysManage.T_PUB_ROLE();
            Model.SysManage.T_PUB_ROLE roleModel = roleBll.GetModel(strID);
            if (roleModel != null)
            {
                txtRoleName.Text = roleModel.ROLE_NAME;
                txtReMark.Text = roleModel.REMAEK;
            }
        }
        //提交
        protected void btnSend_Click(object sender, EventArgs e)
        {
            string strCommand = btnSend.CommandName;
            BLL.SysManage.T_PUB_ROLE roleBll = new BLL.SysManage.T_PUB_ROLE();
            Model.SysManage.T_PUB_ROLE roleModel;
            if (strCommand.Equals("edit"))
            {
                string strID = btnSend.CommandArgument.Trim();
                roleModel = roleBll.GetModel(strID);
            }
            else
            {
                roleModel = new Model.SysManage.T_PUB_ROLE();
            }
            roleModel.ROLE_NAME = txtRoleName.Text.Trim();
            roleModel.REMAEK = txtReMark.Text.Trim();
            if (strCommand.Equals("edit"))
            {
                roleBll.Update(roleModel);
            }
            else
            {
                roleBll.Add(roleModel);
            }
            Universal.JS.RunJS("GoBack()");
        }

       
    }
}